<?php
/**
 * Copyright (c) 2014-2018, www.kuacg.com
 * All right reserved.
 *
 * @since LTS-181021
 * @package Cute
 * @author 酷ACG资源网
 * @date 2018/10/21 10:00
 * @link https://www.kuacg.com/23856.html
 */
?>
<?php

/**
 * Class search
 */
class search extends WP_Widget {
    function __construct() {
        parent::__construct(false, __('TT-搜索工具', 'tt'), array( 'description' => __('Cute专用搜索小工具', 'tt') ,'classname' => 'widget_search wow bounceInRight'));
    }

        function widget($args, $instance) {
        // parent::widget($args, $instance); // TODO: Change the autogenerated stub
        // extract($args);
        wp_reset_postdata();
        
        ?>
        <?php echo $args['before_widget']; ?>
        <form role="search" method="get" id="searchform" class="searchform" action="<?php echo get_home_url(); ?>">
        <div style="text-align:center">
        <label class="screen-reader-text" for="s">搜索：</label>
        <input type="text" name="s" placeholder="输入内容搜索一下吧" style="height:30px;padding: 0 5px 0 5px;width: 50%;">
        <button type="submit" class="btn btn-success" id="searchsubmit" value="搜索" style="position:relative;width: 20%;height:30px;margin-left:10px;padding: 0!important;vertical-align: baseline!important;">搜索</button>
        </div></form>
        <?php echo $args['after_widget']; ?>
        <?php
    }

    function update($new_instance, $old_instance) {
        return $new_instance;
    }

    function form($instance) {
        ?>
        <p>提示：此工具无需配置，直接使用</p>
        <?php
    }
}

/* 注册小工具 */
if ( ! function_exists( 'tt_register_widget_search' ) ) {
    function tt_register_widget_search() {
        register_widget( 'search' );
    }
}
add_action( 'widgets_init', 'tt_register_widget_search' );